package com.ruoyi.api.worker;

import com.github.pagehelper.PageHelper;
import com.ruoyi.system.utils.TokenUtil;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.JiajiaMessage;
import com.ruoyi.system.service.IJiajiaMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/worker/message")
@Api(tags = "社工端系统消息接口")
public class ApiWorkerMessageController {

    @Autowired
    private IJiajiaMessageService messageService;

    @ApiOperation(value = "社工系统消息接口")
    @PostMapping("/messageDetail")
    public AjaxResult messageDetail(@RequestParam Integer pageNum){
        JiajiaMessage message = new JiajiaMessage();
        //根据社工id来查询
        message.setUid(TokenUtil.getUid());
        message.setType(1);
        PageHelper.startPage(pageNum,20,"addtime desc");
        List<JiajiaMessage> messageList = messageService.selectJiajiaMessageList(message);

        messageService.yiDuAllMessage(message);

        return AjaxResult.success(messageList);
    }
}
